The Java Native Interface (JNI) provides several Application Program Interface (API) functions for accessing data contained objects such as the data contained in primitive arrays. These functions are specified such that the Java Virtual Machine (JVM) has the option of returning either a copy of the object data or mapping a direct pointer to the object. Returning a pointer to the data of an object (pinning) provides direct access to the object data and is advantageous in terms of memory usage because the JVM avoids the cost of allocating the native memory to contain the data, copy the data from the heap object into the native memory, and possible copy the data back when the array access is completed. Conversely, pinning an object is disadvantageous in terms of garbage collection of the heap because while an object is pinned it cannot be moved, potentially impeding many Garbage Collector (GC) techniques which require object movement to alleviate fragmentation and improve object locality (like techniques such as heap compaction). Therefore, while pointing to an object may alleviate native memory use, a pinned object may prevent a GC from operating efficiently.